/*
 * @Author: your name
 * @Date: 2021-09-03 14:10:04
 * @LastEditTime: 2021-09-03 14:51:00
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day10\5-原型链继承.js
 */

//定义父类类型
function Animal() {
    this.name = "animal";

}
Animal.prototype.sayName = function() {
    console.log(this.name);
}

//定义子类
function Dog() {
    this.color = "black";
}

//继承：将子类构造函数对象的原型指向父类对象的实例
Dog.prototype = new Animal();
Dog.prototype.sayColor = function() {
    console.log(this.color);
}
var dog = new Dog();
console.log(dog); //Animal { color: 'black' }
dog.sayName(); //animal
dog.sayColor(); //black